home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
boe.pres.k12.wv.us
/
boe.pres.k12.wv.us.zip
/
boe.pres.k12.wv.us
/
Utilities
/
Xerox Workcentre 5335
/
Windows Scan
/
32-bit_x86
/
Francais
/
cpsimage.cab
/
data
/
docio
/
checksum.elf
next >
Wrap
Text File
|
2009-03-16
|
1KB
|
48 lines
// $Id: checksum.elf,v 1.3 2007/02/15 16:33:47 wayman Exp $
// Reads the checksums from the reference file and validates with actual image
// use: xipe checksumChecker.elf -imp fn:s "checksumsFilename.txt";
// Format of "checksumFilename.txt" is
// fullImagePathName imageSize imageChecksum
#import "documentio.ucm";
#load "sys/stdio.elf";
#load "docio/fileio.elf";
LoadClasses(filename:"xeng");
// Returns TRUE if the checksum and size of the given file matches the
// given reference values.
PROCEDURE validateChecksum (STRING fn, LONG size, INTEGER checksum)
RETURNS (BOOLEAN valid)
{
valid = FALSE;
DOCUMENTREADER dr = CreateDocumentReader(filename:fn);
if (dr)
{
INTEGER ichecksum = dr.getChecksum();
FILE imageFile = new (FILE, path: fn);
LONG isize = imageFile.getSize();
if ((size == isize) && (checksum == ichecksum))
valid = TRUE;
}
}
// Returns the size and checksum of the image file given.
PROCEDURE getChecksum (STRING fn) RETURNS (LONG size, INTEGER checksum)
{
size = 0;
checksum = 0;
DOCUMENTREADER dr = CreateDocumentReader(filename:fn);
if (dr)
{
checksum = dr.getChecksum();
FILE imageFile = new (FILE, path: fn);
size = imageFile.getSize();
}
}